#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=95
boot() {
	[ -d /tmp/root ] && {
		cat /proc/cpuinfo | grep 7623
		if [ "$?" == "0" ]; then
			mount_root2 done;
		else
			mount_root done;
		fi
	}

	#挂载持久化配置分区
	local __mtd=$(find_mtd_part permanent_config)
	local __flag=`dd if=$__mtd bs=1 count=2 2>/dev/null | hexdump -e '/2 "%02x"'`
	if [[ "$__flag" = "ffff" ]]; then
	echo -n -e $'\xde\xad\xc0\xde' | dd bs=1 seek=0 of=$__mtd count=4 conv=notrunc 2>/dev/null
	fi

	mkdir /permanent_config
	mount -t jffs2 $__mtd /permanent_config >/dev/null 2>&1

	block mount

	# 旧UI升级到新UI时,配置文件适配
	if [[ `factory_ops -g config_adaptor` == "0" ]]; then
		for file in `ls /etc/cfgAdaptor`
		do
			sh /etc/cfgAdaptor/$file
		done
		factory_ops -s config_adaptor 1
	fi

	# process user commands
	[ -f /etc/rc.local ] && {
		sh /etc/rc.local
	}

	# set leds to normal state
	. /etc/diag.sh
	set_state done
}
